package com.oracle.interceptor;

import org.apache.ibatis.plugin.Intercepts;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class AdminInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
       HttpSession session = request.getSession();
       if(session.getAttribute("admin")==null){
           session.setAttribute("noAdmin", "没有登录用户");
           response.sendRedirect(request.getContextPath()+"/adminLoginView");
           return false;
       }
       return true;
    }

}
